//
//  Car.m
//  OCDay7homework
//
//  Created by dllo on 16/5/30.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "Car.h"

@implementation Car
@synthesize name = _name;
@synthesize brand = _brand;
@synthesize price = _price;
-(void)setName:(NSString *)name{
    if(_name != name){
        [_name release];
        _name = [name retain];
    }
}

-(NSString *)name{
    return [[_name retain] autorelease];
}

-(void)setBrand:(NSString *)brand{
    if(_brand != brand){
        [_brand release];
        _brand = [brand retain];
    }
}

-(NSString *)brand{
    return [[_brand retain] autorelease];
}

-(instancetype)initWithName:(NSString *)name withBrand:(NSString *)brand withPrice:(NSInteger)price{
    self = [super init];
    if (self) {
        _name = [name retain];
        _brand = [brand retain];
        _price = price;
    }
    return self;
}

+(instancetype)carWithName:(NSString *)name withBrand:(NSString *)brand withPrice:(NSInteger)price{
    Car *car = [[Car alloc] initWithName:name withBrand:brand withPrice:price];
    return [car autorelease];
}
@end